package net.pimpas.web.jsf.components.ajax.populate;

import javax.faces.context.FacesContext;

import net.pimpas.web.jsf.components.ajax.UIAjax;

public class UIAjaxPopulate extends UIAjax {
	
	public static final String COMPONENT_TYPE			= UIAjax.COMPONENT_TYPE+".populate";
	public static final String COMPONENT_FAMILY			= UIAjax.COMPONENT_FAMILY+".populate";
	public static final String COMPONENT_RENDER_TYPE	= UIAjax.COMPONENT_RENDER_TYPE+".populate";
	
	private String skipValidatorFor;
	private Boolean skipAllValidators;
	
	@Override
	public Object saveState(FacesContext context) {
		Object[] ob = new Object[3];
		ob[0] = super.saveState(context);
		ob[1] = this.getSkipValidatorFor();
		ob[2] = this.getSkipAllValidators();
		
		return ob;
	}
	
	@Override
	public void restoreState(FacesContext context, Object state) {
		Object[] ob = (Object[]) state;
		super.restoreState(context, ob[0]);
		this.setSkipValidatorFor((String) ob[1]);
		this.setSkipAllValidators((Boolean) ob[2]);
	}
	
	@Override
	public String getRendererType() {
		return COMPONENT_RENDER_TYPE;
	}

	@Override
	public String getFamily() {
		return COMPONENT_FAMILY;
	}

	public Boolean getSkipAllValidators() {
		return skipAllValidators;
	}

	public void setSkipAllValidators(Boolean skipAllValidators) {
		this.skipAllValidators = skipAllValidators;
	}

	public String getSkipValidatorFor() {
		return skipValidatorFor;
	}

	public void setSkipValidatorFor(String skipValidatorFor) {
		this.skipValidatorFor = skipValidatorFor;
	}
}